﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class INILibs : MonoBehaviour
{
	/// <summary>
	/// 获取ini文件地址，放在Data文件
	/// </summary>
	/// <param name="export_dir">unity导出的目录名</param>
	/// <param name="ini_file">ini文件</param>
	/// <returns></returns>
	public string GetLocalUrl(string export_dir, string ini_file)
	{
		string soft_name = Application.productName;
		return Application.dataPath.Replace("Assets", export_dir).Replace("/" + soft_name + "_Data", "") + "/" + ini_file;
	}

	/// <summary>
	/// 获取ini文件地址，文件在StreamingAssets下
	/// </summary>
	/// <param name="ini_file">ini文件</param>
	/// <returns></returns>
	public string GetAssetUrl(string ini_file)
	{
		return Application.streamingAssetsPath + "/" + ini_file;
	}


	/// <summary>
	/// 读取ini文件
	/// </summary>
	/// <param name="url"></param>
	/// <returns></returns>
	public Dictionary<string, Dictionary<string, string>> GetIni(string url)
	{
		INIParser ini = new INIParser();
		ini.Open(url);
		Dictionary<string, Dictionary<string, string>> data = ini.Get_Ini();
		ini.Close();
		return data;
	}

}
